/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package angels.modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author AlanmLira
 */
@Entity
@Table(name = "crianca")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Crianca.findAll", query = "SELECT c FROM Crianca c"),
    @NamedQuery(name = "Crianca.findById", query = "SELECT c FROM Crianca c WHERE c.id = :id"),
    @NamedQuery(name = "Crianca.findByNome", query = "SELECT c FROM Crianca c WHERE c.nome = :nome"),
    @NamedQuery(name = "Crianca.findByPerdida", query = "SELECT c FROM Crianca c WHERE c.perdida = :perdida"),
    @NamedQuery(name = "Crianca.findByEncontrada", query = "SELECT c FROM Crianca c WHERE c.encontrada = :encontrada"),
    @NamedQuery(name = "Crianca.findByDevolvida", query = "SELECT c FROM Crianca c WHERE c.devolvida = :devolvida"),
    @NamedQuery(name = "Crianca.findByIdade", query = "SELECT c FROM Crianca c WHERE c.idade = :idade"),
    @NamedQuery(name = "Crianca.findBySexo", query = "SELECT c FROM Crianca c WHERE c.sexo = :sexo"),
    @NamedQuery(name = "Crianca.findByCriancasEvento", query = "SELECT c FROM Crianca c WHERE c.evento.id = :evento"),
    @NamedQuery(name = "Crianca.findByDescricao", query = "SELECT c FROM Crianca c WHERE c.descricao = :descricao")})
public class Crianca implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 60)
    @Column(name = "nome")
    private String nome;
    @Column(name = "perdida")
    @Temporal(TemporalType.TIMESTAMP)
    private Date perdida;
    @Column(name = "encontrada")
    @Temporal(TemporalType.TIMESTAMP)
    private Date encontrada;
    @Column(name = "devolvida")
    @Temporal(TemporalType.TIMESTAMP)
    private Date devolvida;
    @Size(max = 45)
    @Column(name = "idade")
    private String idade;
    @Column(name = "sexo")
    private Character sexo;
    @Size(max = 300)
    @Column(name = "descricao")
    private String descricao;
    @JoinColumn(name = "responsavel", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Responsavel responsavel;
    @JoinColumn(name = "evento", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Evento evento;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "crianca")
    private List<Localizacao> localizacaoList;

    public Crianca() {
    }

    public Crianca(Integer id) {
        this.id = id;
    }

    public Crianca(Integer id, String nome) {
        this.id = id;
        this.nome = nome;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Date getPerdida() {
        return perdida;
    }

    public void setPerdida(Date perdida) {
        this.perdida = perdida;
    }

    public Date getEncontrada() {
        return encontrada;
    }

    public void setEncontrada(Date encontrada) {
        this.encontrada = encontrada;
    }

    public Date getDevolvida() {
        return devolvida;
    }

    public void setDevolvida(Date devolvida) {
        this.devolvida = devolvida;
    }

    public String getIdade() {
        return idade;
    }

    public void setIdade(String idade) {
        this.idade = idade;
    }

    public Character getSexo() {
        return sexo;
    }

    public void setSexo(Character sexo) {
        this.sexo = sexo;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Responsavel getResponsavel() {
        return responsavel;
    }

    public void setResponsavel(Responsavel responsavel) {
        this.responsavel = responsavel;
    }

    public Evento getEvento() {
        return evento;
    }

    public void setEvento(Evento evento) {
        this.evento = evento;
    }

    @XmlTransient
    public List<Localizacao> getLocalizacaoList() {
        return localizacaoList;
    }

    public void setLocalizacaoList(List<Localizacao> localizacaoList) {
        this.localizacaoList = localizacaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Crianca)) {
            return false;
        }
        Crianca other = (Crianca) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "angels.modelo.Crianca[ id=" + id + " ]";
    }
    
}
